
using DslFactory.Utilities.DteCodeModel;
using EnvDTE;
using Microsoft.VisualStudio.Modeling.Diagrams;
using Microsoft.VisualStudio.Modeling;
namespace Dslfactory.wcfLanguage
{
 public partial class UsageConnector
 {
  DataClassUsesDataClasses DataClassUsesDataClasses
  {
   get
   {
    return ModelElement as DataClassUsesDataClasses;
   }
  }


  public override string  GetToolTipText(Microsoft.VisualStudio.Modeling.Diagrams.DiagramItem item)
  {
   return DataClassUsesDataClasses.Type; 
  }

  protected override void InitializeResources(StyleSet classStyleSet)
  {
   base.InitializeResources(classStyleSet);
   UsageConnector.AssociateValueWith(Store, DataClassUsesDataClasses.KindDomainPropertyId);
  }

  protected override void OnAssociatedPropertyChanged(PropertyChangedEventArgs e)
  {
   if (e.NewValue == null)
    return;
   try
   {
    using (Transaction t = Store.TransactionManager.BeginTransaction("changing color"))
    {
     if  ("Kind" == e.PropertyName)
      if (DataClassUsesDataClasses.Kind == (DataMemberKind.Field))
       Color = System.Drawing.Color.CornflowerBlue;
      else
       Color = System.Drawing.Color.Goldenrod;
     t.Commit();
    }

   }
   catch (System.Exception)
   { }

   base.OnAssociatedPropertyChanged(e);
  }
 }
}
